//
//  SEGInviteRecordCountCell.m
//  ExcellentHome
//
//  Created by 揭婧雯 on 2017/2/27.
//  Copyright © 2017年 陈区. All rights reserved.
//

#import "SEGInviteRecordCountCell.h"

@implementation SEGInviteRecordCountCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier
{
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    CGFloat width = (LYScreenWidth() - 30)/4.0; //列宽
    for (int i = 0; i < 4; i++) {
        //标题
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.font = [UIFont systemFontOfSize:13];
        titleLabel.textColor = kColor_2;
        titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).with.offset(15 + width * i);
            make.top.equalTo(self.contentView.mas_top).with.offset(13.5);
            make.width.mas_equalTo(width);
        }];
        //数量
        UILabel *countLabel = [[UILabel alloc] init];
        countLabel.font = [UIFont systemFontOfSize:13];
        countLabel.textColor = kColor_1;
        countLabel.textAlignment = NSTextAlignmentCenter;
//        countLabel.text = @"10人";
        [self.contentView addSubview:countLabel];
        [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).with.offset(15 + width * i);
            make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-13.5);
            make.width.mas_equalTo(width);
        }];
        //分隔线
        if (i != 3) {
            UIView *line = [[UIView alloc] init];
            line.backgroundColor = kColor_L2;
            [self.contentView addSubview:line];
            [line mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(titleLabel.mas_right);
                make.centerY.equalTo(self.contentView.mas_centerY);
                make.width.mas_equalTo(0.5);
                make.height.mas_equalTo(34);
            }];
        }
        
        switch (i) {
            case 0:
                titleLabel.text = @"本周";
                self.thisWeekLabel = countLabel;
                break;
            case 1:
                titleLabel.text = @"上周";
                self.lastWeekLabel = countLabel;
                break;
            case 2:
                titleLabel.text = @"本月";
                self.thisMonthLabel = countLabel;
                break;
            case 3:
                titleLabel.text = @"上月";
                self.lastMonthLabel = countLabel;
                break;
        }
    }
//    UIView* footView = [[UIView alloc] initWithFrame:CGRectMake(0, 65, LYScreenWidth(), 10)];
//    footView.backgroundColor = kColor_bg;
//    [self.contentView addSubview:footView];
}

- (void)updateWithModel:(SEGInviteRecordModel *)model
{
    self.thisWeekLabel.text = [NSString stringWithFormat:@"%@人",model.thisweek];
    self.lastWeekLabel.text = [NSString stringWithFormat:@"%@人",model.lastweek];
    self.thisMonthLabel.text = [NSString stringWithFormat:@"%@人",model.thismonth];
    self.lastMonthLabel.text = [NSString stringWithFormat:@"%@人",model.lastmonth];
}

@end
